package com.typing.alarm.activity;

import com.typing.alarm.R;
import com.typing.alarm.view.AlarmListView;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;

import android.view.Menu;
import android.view.MenuItem;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;


public class AlarmListActivity extends Activity {
	
	private LinearLayout layout;
	private AlarmListView vList;
	private Context mContext;
	/** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.alarm_list);
        mContext = this;
        layout =(LinearLayout)findViewById(R.id.alarm_list);
        vList =new AlarmListView(this);
        layout.addView(vList,new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
        
    }
    @Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		Log.d("MyClothingListActivity", "onActivityResult====>>"+resultCode);
        if (resultCode == Activity.RESULT_OK) //result is OK
        {
        	vList.RefreshData();
        }
	}
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		menu.add(getString(R.string.menu_register));		
		return super.onCreateOptionsMenu(menu);
	}
	@Override
	public boolean onMenuItemSelected(int featureId, MenuItem item) {
		if(item.getTitle().equals(getString(R.string.menu_register))){
			Intent intent = new Intent(mContext, AlarmRegisterActivity.class);
			startActivity(intent);	
		}
		return super.onMenuItemSelected(featureId, item);
	}
}
